package com.ruoyi.web.controller.manage;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.manage.domain.SuitManagement;
import com.ruoyi.manage.service.ISuitManagementService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 婚纱套系Controller
 * 
 * @author ruoyi
 * @date 2021-03-01
 */
@RestController
@RequestMapping("/manage/management")
public class SuitManagementController extends BaseController
{
    @Autowired
    private ISuitManagementService suitManagementService;

    /**
     * 查询婚纱套系列表
     */
    @PreAuthorize("@ss.hasPermi('manage:management:list')")
    @GetMapping("/list")
    public TableDataInfo list(SuitManagement suitManagement)
    {
        startPage();
        List<SuitManagement> list = suitManagementService.selectSuitManagementList(suitManagement);
        return getDataTable(list);
    }

    /**
     * 导出婚纱套系列表
     */
    @PreAuthorize("@ss.hasPermi('manage:management:export')")
    @Log(title = "婚纱套系", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SuitManagement suitManagement)
    {
        List<SuitManagement> list = suitManagementService.selectSuitManagementList(suitManagement);
        ExcelUtil<SuitManagement> util = new ExcelUtil<SuitManagement>(SuitManagement.class);
        return util.exportExcel(list, "management");
    }

    /**
     * 获取婚纱套系详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:management:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(suitManagementService.selectSuitManagementById(id));
    }

    /**
     * 新增婚纱套系
     */
    @PreAuthorize("@ss.hasPermi('manage:management:add')")
    @Log(title = "婚纱套系", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SuitManagement suitManagement)
    {
        return toAjax(suitManagementService.insertSuitManagement(suitManagement));
    }

    /**
     * 修改婚纱套系
     */
    @PreAuthorize("@ss.hasPermi('manage:management:edit')")
    @Log(title = "婚纱套系", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SuitManagement suitManagement)
    {
        return toAjax(suitManagementService.updateSuitManagement(suitManagement));
    }

    /**
     * 删除婚纱套系
     */
    @PreAuthorize("@ss.hasPermi('manage:management:remove')")
    @Log(title = "婚纱套系", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(suitManagementService.deleteSuitManagementByIds(ids));
    }
}
